const Sequelize = require('sequelize');
const sequelize = require('../dbConn.js');

const { STRING, INTEGER, DATE } = Sequelize;

class User extends Sequelize.Model {}
class RouteList extends Sequelize.Model {}
class Routers extends Sequelize.Model {}

User.init(
    {
        id: {
            type: INTEGER,
            allowNull: false,
            autoIncrement: true,
            primaryKey: true,
            unique: true
        },
        username: STRING,
        name: STRING,
        password: STRING,
        token: STRING,
        user_type: STRING,
        avatar: STRING,
        roles: STRING
    },
    {
        sequelize,
        modelName: 'User'
    }
);

RouteList.init(
    {
        id: {
            type: INTEGER,
            allowNull: false,
            autoIncrement: true,
            primaryKey: true,
            unique: true
        },
        user_type: STRING,
        route: STRING
    },
    {
        sequelize,
        modelName: 'RouteList'
    }
);

Routers.init(
    {
        id: {
            type: INTEGER,
            allowNull: false,
            primaryKey: true,
            unique: true
        },
        p_id: STRING,
        name: STRING,
        path: STRING,
        icon: STRING,
        level: INTEGER,
        user_type: STRING
    },
    {
        sequelize,
        modelName: 'Routers'
    }
);

module.exports = {
    User,
    RouteList,
    Routers
};
